import java.util.*;
public class Lab10Task02 {
public static void main(String[] args) {
Scanner kb=new Scanner(System.in);
double h,v;
try{
System.out.print("Enter the volume [cm3] and height [cm] of a cone: ");
v=kb.nextDouble();h=kb.nextDouble();
double r=getRadius(v,h),sa=getSurfaceArea(r,h);
System.out.printf("Surface area = %.2f square cm",sa);
}
catch(InputMismatchException e) {
System.out.print("Error: "+e);}
catch(IllegalArgumentException e) {
System.out.print("Error: "+e);}
kb.close();
}
public static double getRadius(double v,double h) throws IllegalArgumentException{
double r;
if(v<=0||h<0)
throw new IllegalArgumentException();
else {
r=Math.sqrt(3*v/(Math.PI*h));
}
return r;
}
public static double getSurfaceArea(double r,double h) throws IllegalArgumentException{
double s,sa;
if(r<=0||h<0)
throw new IllegalArgumentException();
else {
s=Math.sqrt(h*h+r*r);
sa=Math.PI*r*s+Math.PI*r*r;
}
return sa;	
}
}
